package com.jm.offer.easy;

import java.util.Arrays;

/**
 * @Description https://leetcode-cn.com/problems/zui-xiao-de-kge-shu-lcof/
 * @date 2022/4/21 7:39
 */
public class _40最小k个数 {

    public static void main(String[] args) {
        int[] arr = {8,3,4,5,1,2,6,7};
        int k = 4;
        int[] leastNumbers = getLeastNumbers(arr, k);
        for (int leastNumber : leastNumbers) {
            System.out.println(leastNumber);
        }
    }

    public static int[] getLeastNumbers(int[] arr, int k) {
        Arrays.sort(arr);
        int[] ret = new int[k];
        for (int i = 0; i < k; i++) {
            ret[i] = arr[i];
        }
        return ret;
    }
}
